<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="css3," />





  <link rel="alternate" href="/atom.xml" title="OBKoro1's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2" />






<meta name="description" content="写在前面：在写页面的时候，偶尔有时会遇到下图这两种情况，一种是单词过长时会溢出div，一种是直接换行，导致出现空白区域。这两个情景就需要word-wrap、word-break这两个属性出场来解决了。闲话不扯了，本文主要内容有：word-wrap和word-break属性介绍，使用方法，他们之间的区别，浏览器兼容性，demo链接。需要的朋友可以过来参考下，喜欢的可以点个赞，希望能对大家有所帮助。">
<meta name="keywords" content="css3">
<meta property="og:type" content="article">
<meta property="og:title" content="单词太长导致自动换行，出现空白区域。——word-wrap和word-break">
<meta property="og:url" content="http://yoursite.com/2017/10/11/单词太长导致自动换行，出现空白区域。——word-wrap和word-break/index.html">
<meta property="og:site_name" content="OBKoro1&#39;s Blog">
<meta property="og:description" content="写在前面：在写页面的时候，偶尔有时会遇到下图这两种情况，一种是单词过长时会溢出div，一种是直接换行，导致出现空白区域。这两个情景就需要word-wrap、word-break这两个属性出场来解决了。闲话不扯了，本文主要内容有：word-wrap和word-break属性介绍，使用方法，他们之间的区别，浏览器兼容性，demo链接。需要的朋友可以过来参考下，喜欢的可以点个赞，希望能对大家有所帮助。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/7681b3ea25f4259b7599">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/cd518bb76aa131d9800c">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/01c76f87a127eb7b25fd">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/619c1577018279a50a70">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/3f3a3b26f2b49ab81aa3">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/b55595378c65b88dc2b9">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/e701f4d37b0015b5538e">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/eeea7fe4114814f3b60a">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/29d4016953d5b7e462a2">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/c36fd784b852063b1144">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/3af903320a9cac09f9d5">
<meta property="og:updated_time" content="2019-06-15T06:19:47.652Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="单词太长导致自动换行，出现空白区域。——word-wrap和word-break">
<meta name="twitter:description" content="写在前面：在写页面的时候，偶尔有时会遇到下图这两种情况，一种是单词过长时会溢出div，一种是直接换行，导致出现空白区域。这两个情景就需要word-wrap、word-break这两个属性出场来解决了。闲话不扯了，本文主要内容有：word-wrap和word-break属性介绍，使用方法，他们之间的区别，浏览器兼容性，demo链接。需要的朋友可以过来参考下，喜欢的可以点个赞，希望能对大家有所帮助。">
<meta name="twitter:image" content="https://dn-mhke0kuv.qbox.me/7681b3ea25f4259b7599">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/10/11/单词太长导致自动换行，出现空白区域。——word-wrap和word-break/"/>





  <title>单词太长导致自动换行，出现空白区域。——word-wrap和word-break | OBKoro1's Blog</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?64d57d0b926bbd27431daa89d2e0a76b";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">OBKoro1's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-前端算法">
          <a href="/arithmetic/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            前端算法
          </a>
        </li>
      
        
        <li class="menu-item menu-item-博客最新更新">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            博客最新更新
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/10/11/单词太长导致自动换行，出现空白区域。——word-wrap和word-break/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="OBKoro1">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/hand1.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="OBKoro1's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">单词太长导致自动换行，出现空白区域。——word-wrap和word-break</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-10-11T22:39:48+08:00">
                2017-10-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/css/" itemprop="url" rel="index">
                    <span itemprop="name">css</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/10/11/单词太长导致自动换行，出现空白区域。——word-wrap和word-break/" class="leancloud_visitors" data-flag-title="单词太长导致自动换行，出现空白区域。——word-wrap和word-break">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1,147 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="写在前面："><a href="#写在前面：" class="headerlink" title="写在前面："></a>写在前面：</h2><p>在写页面的时候，偶尔有时会遇到下图这两种情况，一种是单词过长时会溢出div，一种是直接换行，导致出现空白区域。这两个情景就需要word-wrap、word-break这两个属性出场来解决了。闲话不扯了，本文主要内容有：word-wrap和word-break<strong>属性介绍，使用方法，他们之间的区别，浏览器兼容性，demo链接</strong>。需要的朋友可以过来参考下，喜欢的可以点个赞，希望能对大家有所帮助。</p>
<h3 id="应用场景："><a href="#应用场景：" class="headerlink" title="应用场景："></a>应用场景：</h3><p><img src="https://dn-mhke0kuv.qbox.me/7681b3ea25f4259b7599" alt="属性的应用场景"></p>
<h3 id="word-wrap和word-break是什么？"><a href="#word-wrap和word-break是什么？" class="headerlink" title="word-wrap和word-break是什么？"></a>word-wrap和word-break是什么？</h3><p>在mozilla的官网上找到如下的解释：</p>
<p><img src="https://dn-mhke0kuv.qbox.me/cd518bb76aa131d9800c" alt="word-wrap的英文解释"></p>
<p><img src="https://dn-mhke0kuv.qbox.me/01c76f87a127eb7b25fd" alt="word-break的英文解释"></p>
<p>经过翻译：<strong>word-wrap:</strong></p>
<p>css的 word-wrap 属性用来标明<strong>是否允许</strong>浏览器在单词内进行<strong>断句</strong>，这是为了防止当一个字符串太长而找不到它的自然断句点时产生溢出现象。</p>
<p><strong>word-break:</strong></p>
<p>css的 word-break 属性用来标明<strong>怎么样</strong>进行单词内的<strong>断句</strong>。</p>
<h3 id="何谓单词内断句？"><a href="#何谓单词内断句？" class="headerlink" title="何谓单词内断句？"></a>何谓单词内断句？</h3><p><img src="https://dn-mhke0kuv.qbox.me/619c1577018279a50a70" alt=""></p>
<p>这个单词没有发生单词内断句的情况，这个单词太长了，溢出了容器的范围。</p>
<p>下面是发生了单词内断句的情况实例：</p>
<p><img src="https://dn-mhke0kuv.qbox.me/3f3a3b26f2b49ab81aa3" alt=""></p>
<p>这里面分别使用了word-wrap：break-word;和word-break:break-all;这里可以看到，效果是一样的，下面再说说他们的区别。</p>
<h3 id="word-wrap的属性介绍"><a href="#word-wrap的属性介绍" class="headerlink" title="word-wrap的属性介绍"></a>word-wrap的属性介绍</h3><p><img src="https://dn-mhke0kuv.qbox.me/b55595378c65b88dc2b9" alt="w3c：word-wrap"></p>
<h3 id="word-wrap的浏览器支持情况："><a href="#word-wrap的浏览器支持情况：" class="headerlink" title="word-wrap的浏览器支持情况："></a>word-wrap的浏览器支持情况：</h3><p><img src="https://dn-mhke0kuv.qbox.me/e701f4d37b0015b5538e" alt="所有浏览器都支持"></p>
<h3 id="语法："><a href="#语法：" class="headerlink" title="语法："></a>语法：</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">/* 二选一 */</span><br><span class="line">word-wrap: normal;</span><br><span class="line">word-wrap: break-word;</span><br></pre></td></tr></table></figure>
<h3 id="解析："><a href="#解析：" class="headerlink" title="解析："></a>解析：</h3><p>normal就是大家平常见得最多的正常的换行规则，break-word如果长单词超出了一行的长度的话，在一行中有可以换行的标点时就换行，实在没有可以换行的地方时，才在单词中间换行。（这句的解析入下图）</p>
<p><img src="https://dn-mhke0kuv.qbox.me/eeea7fe4114814f3b60a" alt=""></p>
<p>上图就是：一行中<strong>有可以换行的标点时就换行</strong>，<strong>实在没有</strong>可以换行的地方时，<strong>才在单词中间换行</strong></p>
<h3 id="word-break属性的属性介绍："><a href="#word-break属性的属性介绍：" class="headerlink" title="word-break属性的属性介绍："></a>word-break属性的属性介绍：</h3><p><img src="https://dn-mhke0kuv.qbox.me/29d4016953d5b7e462a2" alt="w3c上关于word-break属性的介绍"></p>
<h3 id="浏览器支持："><a href="#浏览器支持：" class="headerlink" title="浏览器支持："></a>浏览器支持：</h3><p><img src="https://dn-mhke0kuv.qbox.me/c36fd784b852063b1144" alt=""></p>
<p>除了opera不支持以外，其他都支持（火狐也从不支持改为支持了）!</p>
<h3 id="语法使用："><a href="#语法使用：" class="headerlink" title="语法使用："></a>语法使用：</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">/* 默认normal */</span><br><span class="line">word-break: normal;</span><br><span class="line">word-break: break-all;</span><br><span class="line">word-break: keep-all;</span><br></pre></td></tr></table></figure>
<p>解析：几个关键字值的含义如下：<br><strong>normal</strong><br>    使用默认的换行规则。</p>
<p><strong>break-all</strong><br>    允许任意非CJK(Chinese/Japanese/Korean)文本间的单词断行。(这里是CJK中文，日文，韩文的意思)</p>
<p><strong>keep-all</strong><br>不允许CJK(Chinese/Japanese/Korean)文本中的单词换行，只能在半角空格或连字符处换行。非CJK文本的行为实际上和normal一致。(<strong>一致性可看下图的demo效果</strong>)</p>
<p><img src="https://dn-mhke0kuv.qbox.me/3af903320a9cac09f9d5" alt=""></p>
<h3 id="word-break-break-all和word-wrap-break-word之间的区别："><a href="#word-break-break-all和word-wrap-break-word之间的区别：" class="headerlink" title="word-break:break-all和word-wrap:break-word之间的区别："></a>word-break:break-all和word-wrap:break-word之间的区别：</h3><p>其实可以从上述demo栗子中看出来：</p>
<p><strong>word-break:break-all</strong>碰到英文单词统统都换行，只要<strong>到了容器的边界就会换行</strong>，<strong>不浪费一点空间</strong>，一点空隙都不放过。</p>
<p>而<strong>word-wrap:break-word</strong>在一行中<strong>有可以换行点时就换行</strong>，<strong>实在没有</strong>可以换行的地方时，<strong>才在单词中间换行。</strong></p>
<p>这里所说的换行点指的是：如空格，或CJK(Chinese/Japanese/Korean)(中文/日文/韩文)之类的，让这些换行点换行，至于对不对齐，好不好看，则不关心，因此，<strong>很容易出现一片一片牛皮癣</strong>一样的空白的情况。</p>
<h2 id="后话："><a href="#后话：" class="headerlink" title="后话："></a>后话：</h2><p>以上就是本文的内容了，<strong>其实大概分清他们的区别，以后碰到这类型问题，知道需要用哪个属性来解决就好了</strong>。</p>
<p><strong>最后</strong>：因为我经常看不懂别人写的分享，所以个人写文比较偏小白，写的不好之处，欢迎指点。然后就是希望看完的朋友点个<strong>喜欢</strong>，也可以<strong>关注</strong>一下我，现在这阶段基本上每个月都不会少于十五篇文章（看到干货我也会进行分享）。码字不易，感谢支持！<br><strong>ps</strong>：目前<strong>待业</strong>，坐标北京，求推荐工作。然后希望我写哪方面的文章可以在底下评论，或者是私信我，虽然写的不好，但我就当这是记录自己成长的一种方式咯。（前提是我会了，如果不会我也会记下来，等会了的时候再更出来。）<br><a href="http://www.jianshu.com/u/8d1dd8c80f06" target="_blank" rel="noopener"></a><strong><a href="https://juejin.im/user/58714f0eb123db4a2eb95372" target="_blank" rel="noopener">掘金个人主页</a>  ，</strong><a href="http://www.jianshu.com/u/8d1dd8c80f06" target="_blank" rel="noopener"><strong>简书主页链接</strong></a>，<strong><a href="http://blog.csdn.net/OBKoro1?skin=dark1" target="_blank" rel="noopener">csdn博客主页链接</a> ，<a href="https://github.com/OBKoro1" target="_blank" rel="noopener">github</a> 。</strong></p>
<p>参考链接：</p>
<p><a href="http://www.zhangxinxu.com/wordpress/2015/11/diff-word-break-break-all-word-wrap-break-word/" target="_blank" rel="noopener">word-break:break-all和word-wrap:break-word的区别</a></p>
<p><a href="http://www.cnblogs.com/2050/archive/2012/08/10/2632256.html" target="_blank" rel="noopener">你真的了解word-wrap和word-break的区别吗？</a></p>
<p><a href="http://www.w3school.com.cn/cssref/pr_word-wrap.asp" target="_blank" rel="noopener">CSS3 word-wrap 属性</a></p>
<p><a href="http://www.w3school.com.cn/cssref/pr_word-break.asp" target="_blank" rel="noopener">CSS3 word-break 属性</a></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>听说，打赏我的人最后都找到了真爱。</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/pay/weixin.jpg" alt="OBKoro1 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/pay/ali.jpg" alt="OBKoro1 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/css3/" rel="tag"><i class="fa fa-tag"></i> css3</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/10/11/关于js、jq零碎知识点/" rel="next" title="关于js、jq零碎知识点">
                <i class="fa fa-chevron-left"></i> 关于js、jq零碎知识点
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/10/11/sass变量详解——你不知道的sass。/" rel="prev" title="sass变量详解——你不知道的sass。">
                sass变量详解——你不知道的sass。 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="/uploads/hand1.jpg"
              alt="OBKoro1" />
          
            <p class="site-author-name" itemprop="name">OBKoro1</p>
            <p class="site-description motion-element" itemprop="description">种一棵树最好的时间是十年前,其次是现在</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives">
            
                <span class="site-state-item-count">105</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">20</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">74</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/OBKoro1" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>GitHub</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://juejin.im/user/58714f0eb123db4a2eb95372" target="_blank" title="掘金">
                  
                    <i class="fa fa-fw fa-globe"></i>掘金</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://obkoro1.com/web_accumulate/" target="_blank" title="前端积累">
                  
                    <i class="fa fa-fw fa-globe"></i>前端积累</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://segmentfault.com/u/obkoro1/articles" target="_blank" title="segmentfault">
                  
                    <i class="fa fa-fw fa-globe"></i>segmentfault</a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#写在前面："><span class="nav-number">1.</span> <span class="nav-text">写在前面：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#应用场景："><span class="nav-number">1.1.</span> <span class="nav-text">应用场景：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#word-wrap和word-break是什么？"><span class="nav-number">1.2.</span> <span class="nav-text">word-wrap和word-break是什么？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#何谓单词内断句？"><span class="nav-number">1.3.</span> <span class="nav-text">何谓单词内断句？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#word-wrap的属性介绍"><span class="nav-number">1.4.</span> <span class="nav-text">word-wrap的属性介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#word-wrap的浏览器支持情况："><span class="nav-number">1.5.</span> <span class="nav-text">word-wrap的浏览器支持情况：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#语法："><span class="nav-number">1.6.</span> <span class="nav-text">语法：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解析："><span class="nav-number">1.7.</span> <span class="nav-text">解析：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#word-break属性的属性介绍："><span class="nav-number">1.8.</span> <span class="nav-text">word-break属性的属性介绍：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#浏览器支持："><span class="nav-number">1.9.</span> <span class="nav-text">浏览器支持：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#语法使用："><span class="nav-number">1.10.</span> <span class="nav-text">语法使用：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#word-break-break-all和word-wrap-break-word之间的区别："><span class="nav-number">1.11.</span> <span class="nav-text">word-break:break-all和word-wrap:break-word之间的区别：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#后话："><span class="nav-number">2.</span> <span class="nav-text">后话：</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2017 &mdash; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">OBKoro1</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">
      156.0k
    </span>
  
</div>




<div>
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span class="site-uv"><i class="fa fa-user"></i> 访问用户： <span class="busuanzi-value" id="busuanzi_value_site_uv">21621</span> 人 </span>
<span class="site-pv"><i class="fa fa-eye"></i> 访问次数： <span class="busuanzi-value" id="busuanzi_value_site_pv">68503</span> 次</span>

</div>



        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  








  



  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("9ANFp60h6oVyxIPGlau3NOA4-gzGzoHsz", "tMdNuKMbFtN4QsekeNVu83TV");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

  

  

</body>
</html>

